package in.miraclesirius.arunachaltimes;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class StoryAdapter extends BaseAdapter {

	private Context context;
	private ArrayList<StoryEntryModel> storyEntries;

	public StoryAdapter() {
	}

	public StoryAdapter(Context context, ArrayList<StoryEntryModel> storyEntries) {
		this.context = context;
		this.storyEntries = storyEntries;
	}

	@Override
	public int getCount() {
		return storyEntries.size();
	}

	@Override
	public Object getItem(int position) {
		return storyEntries.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			LayoutInflater mInflator = (LayoutInflater) context
					.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
			convertView = mInflator.inflate(R.layout.story_list_item, null);
		}

//		ImageView newsImage = (ImageView) convertView
//				.findViewById(R.id.newsimage);
		TextView txtTitle = (TextView) convertView.findViewById(R.id.title);

//		newsImage.setImageURI( Uri.parse(storyEntries.get(position).getThumbnailUrl()));
		txtTitle.setText(storyEntries.get(position).getTitle());

		return convertView;
	}

}
